#pragma once

#include "Connection.hpp"
#include "include/TcpSocket.hpp"
#include "Reactor.hpp"

class ConnectionFactory
{
public:
    static Connection* createListenConnection(int fd, func_t read, uint32_t events, Reactor* svr)
    {
        Connection* conn = new Connection(fd, events, svr);
        conn->setCallBacks(read, nullptr, nullptr);
        return conn;
    }

    static Connection* createNormalConnection(int fd, func_t read, func_t write, func_t except, uint32_t events, Reactor* svr)
    {
        Connection* conn = new Connection(fd, events, svr);
        conn->setCallBacks(read, write, except);
        return conn;
    }

    static Connection* createEventConnection(int efd, func_t read, uint32_t events, Reactor* svr)
    {
        Connection* conn = new Connection(efd, events, svr);
        conn->setCallBacks(read, nullptr, nullptr);
        return conn;
    }
};